wayland/surface: Destroy toplevel present callback if ignored
authorJonas Ådahl <jadahl@gmail.com>
Fri, 7 Aug 2020 07:03:03 +0000 (09:03 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 7 Aug 2020 07:06:21 +0000 (09:06 +0200)
We might break the loop early, e.g. if we're unmapped before the round
trip finishes, and to avoid the callback to write to invalid stack
memory, destroy the callback so it won't be invoked.

Fixes: #3026
gdk/wayland/gdksurface-wayland.c

index fccfa9a0033547147102efb6e255a965a1bee9b1..527e27f7dfc22838847ca5d0731e242fec20c0ef 100644 (file)
@@ -4814,6 +4814,9 @@ gdk_wayland_toplevel_present (GdkToplevel       *toplevel,
          (!impl->initial_configure_received || !done))
     wl_display_dispatch_queue (display_wayland->wl_display, impl->event_queue);
 
+  if (!done)
+    wl_callback_destroy (callback);
+
   if (needs_reconfigure &&
       last_configure_serial == impl->last_configure_serial &&
       !(surface->state & (GDK_SURFACE_STATE_MAXIMIZED |